cmake_minimum_required(VERSION 3.15)
project(cxi_common)
include(../cmake/utils.cmake)

find_package(spdlog REQUIRED)
find_package(cpp-pinyin REQUIRED)
find_package(RapidJSON REQUIRED)
find_package(simdjson REQUIRED)
find_package(yaml-cpp REQUIRED)
find_package(ZLIB REQUIRED CONFIG)
find_package(libzip REQUIRED)
find_package(QXlsxQt5 REQUIRED)
find_package(cryptopp REQUIRED CONFIG)
find_package(qhotkey REQUIRED)
find_package(zint REQUIRED)
find_package(Qt5 COMPONENTS Widgets Core Gui Designer Network REQUIRED)
#get_filename_component(PARENT_DIR "${CMAKE_CURRENT_LIST_DIR}" DIRECTORY)
#set(BOOST_ROOT ${PARENT_DIR}/3rdparty/boost)
#find_package(Boost CONFIG COMPONENTS describe REQUIRED)

add_standard_module(${PROJECT_NAME} include/common ON ON)
target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Network)
target_link_libraries(${PROJECT_NAME} PUBLIC
        spdlog::spdlog
        cpp-pinyin::cpp-pinyin
        rapidjson
        simdjson::simdjson
        QXlsx::QXlsx
        ZLIB::ZLIB
        yaml-cpp::yaml-cpp
        libzip::zip
        cryptopp::cryptopp
        qhotkey
        zint::zint
#        Boost::describe
)
copy_imported_dependencies(${PROJECT_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

# 拷贝cpp-pinyin所需要的dict目录
#file(COPY ${CMAKE_SOURCE_DIR}/3rdparty/windows/cpp-pinyin/share/cpp-pinyin/dict
#        DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

install(TARGETS ${PROJECT_NAME}
        EXPORT CxiCommonPcTargets
        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
        INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})